import React from 'react';
import './createPlayer.scss';
import { userData } from 'js/core/userData';
import { browserHistory, Link } from 'react-router';
import {api} from 'js/api/api';

class CreatePlayer extends React.Component {
    constructor() {
        super()
    }
    handleSubmit = () => {
        let name = this.refs.name.value;
        api('createPlayer', { name: name }, (err, data) => {
            if (err === 0) {
                browserHistory.push('/playerSelect');
            }
        });
    }
    render() {
        return <div id="createPlayer" className="flex-col-hcenter">
            <input className="common" placeholder="用户名" ref="name" />
            <button className="common" onClick={this.handleSubmit}>新建角色</button>
        </div >
    }
}

export default CreatePlayer;